﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;

namespace QL_NOI_TRU
{
    public partial class frmXemBenhAn : DevExpress.XtraEditors.XtraForm
    {
        public frmXemBenhAn()
        {
            InitializeComponent();
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            var f = new frmChiDinhXuatVien();
            f.Show();
        }

        private void frmXemBenhAn_Load(object sender, EventArgs e)
        {
            // đổ dữ liệu vào cbbMaBenhAn
            var maBA = "select MABENHAN from BENH_AN";
            SqlConnection conn = new SqlConnection(frmDangnhap.stringConn);
            SqlCommand cm = conn.CreateCommand();
            cm.CommandText = maBA;
            conn.Open();
            SqlDataReader dr = cm.ExecuteReader();
            while (dr.Read())
            {
                var newVariable = cbbMaBenhAn.Properties.Items.Add(String.Format("{0}", dr["MABENHAN"]));
            }
            dr.Close();
        }

        private void cbbMaBenhAn_SelectedIndexChanged(object sender, EventArgs e)
        {
            string a = cbbMaBenhAn.Text.Trim();
            var maP = "select MAPHIEU from PHIEU_DIEU_TRI where MABENHAN = '"+a+"' ";
            SqlConnection conn = new SqlConnection(frmDangnhap.stringConn);
            SqlCommand cm = conn.CreateCommand();
            cm.CommandText = maP;
            conn.Open();
            SqlDataReader dr = cm.ExecuteReader();
            while (dr.Read())
            {
                var newVariable = cbbMaPhieu.Properties.Items.Add(String.Format("{0}", dr["MAPHIEU"]));
            }
        }

    }
}